package com.newer.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newer.domain.User;
import com.newer.dto.LoginDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {

    @Select("select u.*,ru.srId,r.*,rt.trId,t.* from t_role_user ru inner join t_user u on ru.userId=u.userId inner join t_role r on ru.roleId=r.roleId inner join t_role_trre rt on rt.roleId=r.roleId inner join t_trre t on rt.trreId=t.trreId where userName=#{username} and userPwd=#{userpwd}")
    @Results({
            @Result(column = "userId",property = "userId"),
            @Result(column = "userName",property = "userName"),
            @Result(column = "userPwd",property = "userPwd"),
            @Result(column = "realName",property = "realName"),
            @Result(column = "phone",property = "phone"),
            @Result(column = "state",property = "state"),
            @Result(column = "img",property = "img"),
            @Result(column = "roleName",property = "roleName"),
            @Result(column = "trreId",property = "trreId"),
            @Result(column = "trreName",property = "trreName"),
            @Result(column = "url",property = "url"),
    })
    List<LoginDto>   selectNamePwd( String  username, String  userpwd);

}